
import 'package:flutter/services.dart';
import 'package:flutter/cupertino.dart';

import 'package:flutter/material.dart';
import 'package:flutterapp1/color/MyColor.dart';

class AppNavi extends PreferredSize{
  AppNavi({Key key, this.title,this.backgroundColor,this.textColor,this.showBack,this.closeBack,this.onPressed}) : super(preferredSize:Size.fromHeight(44+ AppStatusBar));
  final String title;
  final Color backgroundColor;
  final Color textColor;
  final bool  showBack;//default true
  final bool  closeBack;//default false
  final GestureTapCallback onPressed;
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(top: 0),
      width: AppWidth,
      height: 44 + AppStatusBar,
      color: backgroundColor,
      child: new Row(
        children: <Widget>[
          new Offstage(
            offstage: showBack == null ? false : true,
            child:Container(
              margin: EdgeInsets.only(left:0,top: AppStatusBar),
              width: 44,
              height: 44,
              child: IconButton(
                color: MyColor.AppFFFFFF,
                icon:new Icon(closeBack == null ? Icons.arrow_back : Icons.close),
                onPressed: onPressed == null ?  (){
                  Navigator.of(context).pop();
                } : onPressed,
              ),
            ),
          ),
          new Container(
            margin: EdgeInsets.only(top: 10 + AppStatusBar),
            width: AppWidth - (showBack == null ? 88 : 0),
            height: 44,
            child:Text(title,textAlign: TextAlign.center,style:TextStyle(color: textColor,fontSize: 18),),
          ),
//          new Container(
//            margin: EdgeInsets.only(right: 0,top: AppStatusBar),
//            width: 44,
//            height: 44,
//          ),
        ],
      ),
    );
  }


}

class AppHomeNavi extends PreferredSize{
  AppHomeNavi({Key key, this.title}) : super(preferredSize:Size.fromHeight(44+ AppStatusBar));
  final Widget title;
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(top: 0),
      width: AppWidth,
      height: 44 + AppStatusBar,
      color: MyColor.AppColor,
      child: new Row(
        children: <Widget>[
          new Container(
            margin: EdgeInsets.only(top: 10 + AppStatusBar),
            width: AppWidth,
            height: 44,
            child: title,
          ),
        ],
      ),
    );
  }
}
